package com.gopay.solution.dao.smelly.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.cps.CpsAcctProdMast;
import com.gopay.solution.dao.smelly.CpsAcctProdMastTempDAO;

/**
 * @CpsAcctProdMastTempDAOImpl.java
 * @author MA HUAN
 * @2013-4-11 下午4:30:57  www.gopay.com.cn Inc.All rights reserved.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Repository(value="cpsAcctProdMastTempDAO")
public class CpsAcctProdMastTempDAOImpl extends BaseDAOImpl<CpsAcctProdMast, Serializable> implements CpsAcctProdMastTempDAO{
    
    @Override
    public boolean setProdLineIdForAcctProd(final String newProdLineId, final List<String> acctProdCodes) {
        
        if(StringUtils.isEmpty(newProdLineId) || acctProdCodes == null || acctProdCodes.isEmpty()) {
            return false;
        }
        
        final String hql = "update CpsAcctProdMast capm set capm.prodLineId = :ProdLineId where capm.prodCode in (:ProdCodeList)";
        
        Map params = new HashMap();
        params.put("ProdLineId", newProdLineId);
        params.put("ProdCodeList", acctProdCodes);
        
        int ret = super.updateByHql(hql, params);
        
        return ret == acctProdCodes.size();
    }

}
